# -*- coding: utf-8 -*-
import logging

def is_available_time(a_class, b_class):
    if a_class.start_time < b_class.end_time:
        return False
    if a_class.end_time > b_class.start_time:
        return False
    return True

def is_available_equipment(a_class, booth):
    if a_class.classproperty.equipment in ('Polycom', 'lifesize'):
        if booth.equipment != 'Polycom':
            return False
    return True

def _kr(str):
    return unicode(str).encode('euc-kr')

def _kr_u_(str):
    return unicode(str, 'utf-8').encode('euc-kr')

def e_u(str):
    return unicode(_content, 'euc-kr').encode('utf-8')

def short_name_(name):
    if not name:
        return ''
    return ''.join([c for c in name if not c.islower() ])

def kr_stage_(stage):
    if not stage:
        return ''
    if stage == 'P':
        return u'초등학교'
    elif stage == 'M':
        return u'중학교'
    elif stage == 'GM':
        return u'여자중학교'
    elif stage == 'H':
        return u'고등학교'
    elif stage == 'GH':
        return u'여자고등학교'
    else:
        return stage

def en_stage_(stage):
    if not stage:
        return ''
    if stage == 'P':
        return 'Primary School'
    elif stage == 'M':
        return 'Middle School'
    elif stage == 'GM':
        return 'Girls Middle School'
    elif stage == 'H':
        return 'High School'
    elif stage == 'GH':
        return 'Girls High School'
    else:
        return stage

def kr_province_(province):
    if not province:
        return ''
    if province == 'KN':
        return u'경남'
    elif province == 'KB':
        return u'경북'
    elif province == 'CN':
        return u'충남'
    elif province == 'CB':
        return u'충북'
    elif province == 'US':
        return u'울산'
    else:
        return province

def kr_money_(money):
    if not isinstance(money, str):
        money = str(money)
    d = {
         '1': u'일',
         '2': u'이',
         '3': u'삼',
         '4': u'사',
         '5': u'오',
         '6': u'육',
         '7': u'칠',
         '8': u'팔',
         '9': u'구',
         }
    u = (u'', u'십', u'백', u'천')
    uu = (u'원', u'만', u'억', u'조')
    s, k = '', 0
    for i, n in enumerate(money[::-1]):
        j = i % 4
        if j == 0:
            s = uu[k] + s
            k = k + 1
        if n != '0':
            s = d[n] + u[j]  + s
    return ''.join(s)

